#include "ComputeRhoMaterial.h"
#include<iostream>
#include "libmesh/quadrature.h"
#include <limits>
using std::cout;
using std::endl;
registerMooseObject("TrilobitaApp", ComputeRhoMaterial);
template<>
InputParameters validParams<ComputeRhoMaterial>()
{
  InputParameters params = validParams<Material>();
  params.addParam<Real>("volume_fraction_A", 0, "volume fraction of phaseA");
  params.addParam<Real>("volume_fraction_B", 0, "volume fraction of phaseB");
  params.addParam<Real>("volume_fraction_C", 0, "volume fraction of phaseC");
  params.addRequiredCoupledVar("rho_A", "Coupled density for pahseA");
  params.addRequiredCoupledVar("rho_B", "Coupled density for pahseB");
  params.addRequiredCoupledVar("rho_C", "Coupled density for pahseC");
  return params;
}


ComputeRhoMaterial::ComputeRhoMaterial(const InputParameters & parameters) :
    	    Material(parameters),
		_rhos(declareProperty<Real>("solid_density")),
		_drhos_dt(declareProperty<Real>("drhos_dt")),
		_rho_A_value(coupledValue("rho_A")),
		_rho_B_value(coupledValue("rho_B")),
		_rho_C_value(coupledValue("rho_C")),
		_rho_A_dt(coupledDot("rho_A")),
		_rho_B_dt(coupledDot("rho_B")),
		_rho_C_dt(coupledDot("rho_C"))
{
	_volume_fraction_A_value = getParam<Real>("volume_fraction_A");
	_volume_fraction_B_value = getParam<Real>("volume_fraction_B");
	_volume_fraction_C_value = getParam<Real>("volume_fraction_C");
}



void
ComputeRhoMaterial::initQpStatefulProperties()
{

	_rhos[_qp] = _rho_A_value[_qp] * _volume_fraction_A_value + _rho_B_value[_qp] * _volume_fraction_B_value + _rho_C_value[_qp] * _volume_fraction_C_value;
	_drhos_dt[_qp] = _rho_A_dt[_qp] * _volume_fraction_A_value + _rho_B_dt[_qp] * _volume_fraction_B_value + _rho_C_dt[_qp] * _volume_fraction_C_value;
}
void ComputeRhoMaterial::computeQpProperties()
{
	_rhos[_qp] = _rho_A_value[_qp] * _volume_fraction_A_value + _rho_B_value[_qp] * _volume_fraction_B_value + _rho_C_value[_qp] * _volume_fraction_C_value;
	_drhos_dt[_qp] = _rho_A_dt[_qp] * _volume_fraction_A_value + _rho_B_dt[_qp] * _volume_fraction_B_value + _rho_C_dt[_qp] * _volume_fraction_C_value;
}


